<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE HTML>
<html>
<head>

    <title>My JSP 'index.jsp' starting page</title>

</head>

<body>
<div>
    <h2>图书${user.usertype }欢迎您!</h2>
    <table border="1" style= "width:700px">
        <thead>图书详细信息列表</thead>
        <tr>
            <td>书名</td>
            <td>作者</td>
            <td>出版社</td>
            <td>出版日期</td>
            <td>页数</td>
            <td>价格</td>
            <td>内容摘要</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pageBean.list }" var="b" varStatus="v">
            <tr style="${v.index%2==0 ? 'background: ;' : 'background:#FFA500'}">
                <td>${b.name }</td>
                <td>${b.author }</td>
                <td>${b.publish }</td>
                <td><fmt:formatDate value="${b.publishdate }"  pattern="yyyy-MM-dd"/></td>
                <td>${b.page }</td>
                <td>${b.price }</td>
                <td>${b.content }</td>
                <td><a href="${pageContext.request.contextPath }/toUpdate?id=${b.id}">修改</a>&nbsp;&nbsp;
                    <a href="${pageContext.request.contextPath }/remove?id=${b.id}">删除</a></td>
            </tr>
        </c:forEach>
    </table>
    <a href="add.jsp"><input type="button" value="新增图书"/></a>共${pageBean.totalCount}条记录
    <a href="${pageContext.request.contextPath }/list?pageIndex=1">第一页</a>
    <a href="${pageContext.request.contextPath }/list?pageIndex=${pageBean.pageIndex-1}">上一页</a>
    <a href="${pageContext.request.contextPath }/list?pageIndex=${pageBean.pageIndex+1}">下一页</a>
    <a href="${pageContext.request.contextPath }/list?pageIndex=${pageBean.totalPage}">最后一页</a>
</div>
</body>
</html>